*===============================================================================
*
*					WORKER BELIEFS ABOUT OUTSIDE OPTIONS
*		(c)	Simon Jaeger, Christopher Roth, Nina Roussille, Benjamin Schoefer
*							  2023 December 5
*						   	   	 Local Data 
*
*===============================================================================


********************************************************************************
*								Table F01									   *
********************************************************************************

use "$temp/experiment1.dta", clear

* summarize tenure 
su tenure
su tenure if prespecified==1 

* control group mean of vars with no IV 
su bias_belief_post_pct_w2 posttreatment_wagechange_pct_w2 if personalinfo==0
su bias_belief_post_pct_w2 posttreatment_wagechange_pct_w2 if personalinfo==0 & prespecified==1
su bias_belief_post_pct_w2 posttreatment_wagechange_pct_w2 if personalinfo==0 & prespecified==1 & correct==0 

* 5 Columns: All, No Treatment, All/Only AKM, All/Only Personal and Both
tab personalinfo

matrix J=J(20,8,.)

forvalues var =0/1{
	local col = `var' + 6

	* Gender
	sum gender
	mat J[1,1] = r(N)
	mat J[2,1] = r(mean)
	sum gender if treatmentinfo==`var'
	mat J[1,`col'] = r(N)
	mat J[2,`col'] = r(mean)
	prtest gender, by(treatmentinfo)
	mat J[2,8] = r(p)
	
	* Age
	sum age, d
	mat J[3,1] = r(mean)
	mat J[3,2] = r(sd)
	mat J[3,3] = r(p10)
	mat J[3,4] = r(p50)
	mat J[3,5] = r(p90)
	sum age if treatmentinfo==`var'
	mat J[3,`col'] = r(mean)
	ttest age, by(treatmentinfo)
	mat J[3,8] = r(p)
	
	* Pre-Tax Wage 
	sum pretaxwageearning, d
	mat J[4,1] = r(mean)
	mat J[4,2] = r(sd)
	mat J[4,3] = r(p10)
	mat J[4,4] = r(p50)
	mat J[4,5] = r(p90)
	sum pretaxwageearning if treatmentinfo==`var'
	mat J[4,`col'] = r(mean)
	ttest pretaxwageearning, by(treatmentinfo)
	mat J[4,8] = r(p)	
	
	* Education
	sum loweducation
	mat J[5,1] = r(mean)
	sum loweducation if treatmentinfo==`var'
	mat J[5,`col'] = r(mean)
	prtest loweducation, by(treatmentinfo)
	mat J[5,8] = r(p)
	
	sum mediumeducation
	mat J[6,1] = r(mean)
	sum mediumeducation if treatmentinfo==`var'
	mat J[6,`col'] = r(mean)
	prtest mediumeducation, by(treatmentinfo)
	mat J[6,8] = r(p)
	
	sum higheducation
	mat J[7,1] = r(mean)
	sum higheducation if treatmentinfo==`var'
	mat J[7,`col'] = r(mean)
	prtest higheducation, by(treatmentinfo)
	mat J[7,8] = r(p)
	
	* Employment Info 
	sum tarif_ja_nein
	mat J[8,1] = r(mean)
	sum tarif_ja_nein if treatmentinfo==`var'
	mat J[8,`col'] = r(mean)
	prtest tarif_ja_nein, by(treatmentinfo)
	mat J[8,8] = r(p)	
	
	* Top 3 States (90 283 492)
	forvalues i =1/3{
		local row = 8 + `i'
		sum state`i'
		mat J[`row',1] = r(mean)
		sum state`i' if treatmentinfo==`var'
		mat J[`row',`col'] = r(mean)
		prtest state`i', by(treatmentinfo)
		mat J[`row',8] = r(p)	
	}
	
	sum hoursworked, d 
	mat J[12,1] = r(mean)
	mat J[12,2] = r(sd)
	mat J[12,3] = r(p10)
	mat J[12,4] = r(p50)
	mat J[12,5] = r(p90)
	sum hoursworked if treatmentinfo==`var'
	mat J[12,`col'] = r(mean)
	ttest hoursworked, by(treatmentinfo)
	mat J[12,8] = r(p)	
	
	sum sizeemployer_w2, d
	mat J[13,1] = r(mean)
	mat J[13,2] = r(sd)
	mat J[13,3] = r(p10)
	mat J[13,4] = r(p50)
	mat J[13,5] = r(p90)
	sum sizeemployer_w2 if treatmentinfo==`var'
	mat J[13,`col'] = r(mean)
	ttest sizeemployer_w2, by(treatmentinfo)
	mat J[13,8] = r(p) 
	
	sum tenure, d
	mat J[14,1] = r(mean)
	mat J[14,2] = r(sd)
	mat J[14,3] = r(p10)
	mat J[14,4] = r(p50)
	mat J[14,5] = r(p90)
	sum tenure if treatmentinfo==`var'
	mat J[14,`col'] = r(mean)
	ttest tenure, by(treatmentinfo)
	mat J[14,8] = r(p)	
	
	sum employmenthistory, d
	mat J[15,1] = r(mean)
	mat J[15,2] = r(sd)
	mat J[15,3] = r(p10)
	mat J[15,4] = r(p50)
	mat J[15,5] = r(p90)
	sum employmenthistory if treatmentinfo==`var'
	mat J[15,`col'] = r(mean)
	ttest employmenthistory, by(treatmentinfo)
	mat J[15,8] = r(p)	
	
	sum prior_info1, d
	mat J[16,1] = r(mean)
	mat J[16,2] = r(sd)
	mat J[16,3] = r(p10)
	mat J[16,4] = r(p50)
	mat J[16,5] = r(p90)
	sum prior_info1 if treatmentinfo==`var'
	mat J[16,`col'] = r(mean)
	ttest prior_info1, by(treatmentinfo)
	mat J[16,8] = r(p)	
	
	* Bias:
	sum bias_belief_w2, d
	mat J[17,1] = r(mean)
	mat J[17,2] = r(sd)
	mat J[17,3] = r(p10)
	mat J[17,4] = r(p50)
	mat J[17,5] = r(p90)
	sum bias_belief_w2 if treatmentinfo==`var'
	mat J[17,`col'] = r(mean)
	ttest bias_belief_w2, by(treatmentinfo)
	mat J[17,8] = r(p)	
	
	sum bias_belief_pct_w2, d
	mat J[18,1] = r(mean)
	mat J[18,2] = r(sd)
	mat J[18,3] = r(p10)
	mat J[18,4] = r(p50)
	mat J[18,5] = r(p90)
	sum bias_belief_pct_w2 if treatmentinfo==`var'
	mat J[18,`col'] = r(mean)
	ttest bias_belief_pct_w2, by(treatmentinfo)
	mat J[18,8] = r(p)	
	
	* Beliefs
	sum pretreatment_wagechange_w2, d
	mat J[19,1] = r(mean)
	mat J[19,2] = r(sd)
	mat J[19,3] = r(p10)
	mat J[19,4] = r(p50)
	mat J[19,5] = r(p90)
	sum pretreatment_wagechange_w2 if treatmentinfo==`var'
	mat J[19,`col'] = r(mean)
	ttest pretreatment_wagechange_w2, by(treatmentinfo)
	mat J[19,8] = r(p)	
	
	sum pretreatment_wagechange_pct_w2, d
	mat J[20,1] = r(mean)
	mat J[20,2] = r(sd)
	mat J[20,3] = r(p10)
	mat J[20,4] = r(p50)
	mat J[20,5] = r(p90)
	sum pretreatment_wagechange_pct_w2 if treatmentinfo==`var'
	mat J[20,`col'] = r(mean)
	ttest pretreatment_wagechange_pct_w2, by(treatmentinfo)
	mat J[20,8] = r(p)	

}

frmttable using "$tab/TableF01.tex", fragment tex statmat(J) replace ///
ctitle("" , "Mean" ,"SD", "P10", " Median", "P90", "Control (Mean)","Treatment (Mean)","P-Value") ///
sdec(0\3,3,3,3,3,3,3,3\1,1,1,1,1,1,1,3\0,0,0,0,0,0,0,3\3,3,3,3,3,3,3,3\3,3,3,3,3,3,3,3\3,3,3,3,3,3,3,3\3,3,3,3,3,3,3,3\3,3,3,3,3,3,3,3\3,3,3,3,3,3,3,3\3,3,3,3,3,3,3,3\3,3,3,3,3,3,3,3\0,0,0,0,0,0,0,3\3,3,3,3,3,3,3,3\3,3,3,3,3,3,3,3\3,3,3,3,3,3,3,3\3,3,3,3,3,3,3,3\3,3,3,3,3,3,3,3\3,3,3,3,3,3,3,3\3,3,3,3,3,3,3,3) ///
rtitles("\textbf{General Stats}  & \\ &  \\ Number of Respondents" ///
\ "Share of Women" \ "Age in Years"  \ "Pre-Tax Wage (in EUR, per Month)" \ "No Qualifications" \ "Vocational Qualification" \ "University Qualification"  ///
\ "Share in Nordrhein-Westfalen " \ "Share in Bavaria" ///
\ "Share in Baden-Wuerttemberg"  \ ///
"\\ \textbf{Job Specific Stats}  & \\ &  \\ Wage according to CBA" \ ///
 "Weekly Working Hours" \ ///
"Size of Employer" \ "Tenure in Years"  \ "Number of Previous Employer" \ "Number of Wage Investigations" \ ///
"\\ \textbf{Experiment Specific Stats} & \\ & \\ Average Bias (in Euro)" ///
\ "Average Bias (in \%)" \ "Pretreatment Beliefs: Wage Change (in Euro)" \ "Pretreatment Beliefs:  Wage Change (in \%)" )
